<extend name="../Public/base" />
<block name="title">{$TITLE}列表</block>
<block name="body">
    <form action="{:U('menu/updateSort')}" method="post">
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="l">
                <a title="添加菜单" href="javascript:;" CLASS="btn btn-primary radius" onclick="layer_show('添加菜单','{:U('add',array('parent_id'=>$var['menu_id']))}','800','620')">
                    <i class="Hui-iconfont">&#xe600;</i> 添加{$TITLE}
                </a>
            </span>
            <span class="r"><button class="btn btn-default radius" type="submit"><i class="Hui-iconfont">&#xe68f;</i> 更新排序</button></span>
         </div>
        <div class="mt-20">
            <span class="label label-warning radius ">注意：</span>
            <span class="c-999">
                这里主要管理后台的菜单，通常后台的基本权限是和这类菜单关联的！
            </span>
        </div>
        <div class="mt-20">
            <table class="table table-border table-bordered table-bg">
            <thead>
                <tr class="text-c">
                    <th width="5%">ID</th>
                    <th width="25%">排序</th>
                    <th width="20%">菜单名称</th>
                    <th width="25%">规则</th>
                    <th width="5%">状态</th>
                    <th width="20%">操作</th>
                </tr>
            </thead>
            <tbody>
            <foreach name="menus" item="var">

                <if condition="($var.parent_id eq 0)">
                    <tr class="active">
                        <td class="text-c">{$var.menu_id}</td>
                        <td>
                            <input name="sorts[{$var.menu_id}]" value="{$var.sort}" type="text" class="input-text text-c"  style="width: 120px" />
                        </td>
                        <td>{$var.menu_name}</td>
                        <td>{$var.app}</td>
                        <td>
                            <eq name='var.status' value='1'>
                                <span class="label label-success radius">已启用</span>
                                <else/>
                                <span class="label radius">已停用</span>
                            </eq>
                        </td>
                        <td class="text-c">
                           <a title="添加子菜单" href="javascript:;" onclick="layer_show('添加子{$TITLE}','{:U('add',array('parent_id'=>$var['menu_id']))}','800','620')">
                               添加子{$TITLE}
                            </a>
                            <eq name='var.status' value='1'>
                                <a  onclick="change_status('{$var.menu_id}')" href="javascript:;" title="停用" class="ml-5"><i class="Hui-iconfont">&#xe631;</i></a>
                                <else/>
                                <a  onclick="change_status('{$var.menu_id}')" href="javascript:;" title="启用" class="ml-5"><i class="Hui-iconfont">&#xe615;</i></a>
                            </eq>
                            <a title="编辑" href="javascript:;" onclick="layer_show('编辑','{:U('edit',array('menu_id'=>$var['menu_id']))}','800','620')" class="ml-5">
                                <i class="Hui-iconfont">&#xe6df;</i>
                            </a>
                            <a title="删除" href="javascript:;" onclick="del('{$var['menu_id']}','menu_id')" class="ml-5">
                                <i class="Hui-iconfont">&#xe6e2;</i>
                            </a>
                        </td>
                    </tr>
                    <foreach name="menus" item="var2">
                        <eq name="var2.parent_id" value="$var.menu_id">
                            <tr>
                                <td class="text-c">{$var2.menu_id}</td>
                                <td style="padding-left: 80px;">
                                    <input class="input-text text-c" name="sorts[{$var2.menu_id}]" value="{$var2.sort}" type="text" style="width: 120px" />
                                </td>
                                <td>{$var2.menu_name}</td>
                                <td>{$var2.app}</td>
                                <td>
                                    <eq name='var2.status' value='1'>
                                        <span class="label label-success radius">已启用</span>
                                        <else/>
                                        <span class="label radius">已停用</span>
                                    </eq>
                                </td>
                                <td class="text-c">
                                    <a title="模块控制" href="javascript:;" onclick="layer_show('模块控制','{:U('actionEdit',array('parent_id'=>$var2['menu_id']))}','800','500')" class="ml-10">
                                        模块控制
                                    </a>
                                    <eq name='var2.status' value='1'>
                                        <a  onclick="change_status('{$var2.menu_id}')" href="javascript:;" title="停用" class="ml-5"><i class="Hui-iconfont">&#xe631;</i></a>
                                        <else/>
                                        <a  onclick="change_status('{$var2.menu_id}')" href="javascript:;" title="启用" class="ml-5"><i class="Hui-iconfont">&#xe615;</i></a>
                                    </eq>
                                    <a title="编辑" href="javascript:;" onclick="layer_show('编辑菜单','{:U('edit',array('menu_id'=>$var2['menu_id']))}','800','620')" class="ml-5">
                                        <i class="Hui-iconfont">&#xe6df;</i>
                                    </a>
                                    <a title="删除" href="javascript:;" onclick="del('{$var2['menu_id']}','menu_id')" class="ml-5">
                                        <i class="Hui-iconfont">&#xe6e2;</i>
                                    </a>
                                </td>
                            </tr>
                        </eq>
                    </foreach>
                </if>

            </foreach>
            </tbody>
        </table>
    </div>
    <div class='paging_simple_numbers'>
        {$page}
    </div>
  </form>
</block>
<block name="js">
    <script type="text/javascript">
        function change_status(id) {
            action('确认要改变菜单状态吗？',id,"{:U('changeStatus')}",'menu_id');
        }
    </script>
</block>